package com.book.controller;

import com.book.service.LoadImageService;
import com.book.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/**
 * @author yicheng
 */
@RestController
@RequestMapping("/loadImg")
public class UploadImgController {

    @Autowired
    private LoadImageService imageService;

    @PostMapping("/head")
    public ResponseResult loadImage(@RequestParam("userId") String userId,@RequestParam("file")MultipartFile multipartFile){
        return imageService.loadHead(userId,multipartFile);
    }

    //这是上传帖子图片的路径
    @PostMapping("/post")
    public ResponseResult loadPostImage(@RequestParam("userId") String userId,@RequestParam("file")MultipartFile multipartFile){
        return imageService.loadPostHead(userId,multipartFile);
    }

    @PostMapping("/bookImg")
    public ResponseResult loadBookImage(@RequestParam("bookId") String bookId,@RequestParam("file")MultipartFile multipartFile){
        return imageService.loadBookImage(bookId,multipartFile);
    }

    @PostMapping("/carousel")
    public ResponseResult loadCarousel(@RequestParam("file")MultipartFile multipartFile){
        return imageService.loadCarousel(multipartFile);
    }
}
